package com.example.anpapi.entity.po.novelmodel.Novel;

import com.baomidou.mybatisplus.annotation.*;
import com.example.anpapi.entity.po.novelmodel.Novel.NovelStatus;
import com.example.anpapi.entity.po.novelmodel.Novel.NovelVisibility;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@TableName("novels")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Novel implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 作品ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 作者ID（用户服务中的作者ID）
     */
    @TableField("author_id")
    private Long authorId;

    /**
     * 作品标题
     */
    @TableField("title")
    private String title;

    /**
     * 封面图片
     */
    @TableField("cover_image")
    private String coverImage;

    /**
     * 作品描述
     */
    @TableField("description")
    private String description;

    /**
     * 分类ID
     */
    @TableField("category_id")
    private Long categoryId;

    /**
     * 标签数组
     */
    @TableField(value = "tags", typeHandler = com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler.class)
    private List<String> tags;

    /**
     * 状态
     */
    @TableField("status")
    private NovelStatus status;

    /**
     * 可见性
     */
    @TableField("visibility")
    private NovelVisibility visibility;

    /**
     * 总字数
     */
    @TableField("word_count")
    private Integer wordCount;

    /**
     * 章节数
     */
    @TableField("chapter_count")
    private Integer chapterCount;

    /**
     * 阅读数
     */
    @TableField("read_count")
    private Integer readCount;

    /**
     * 点赞数
     */
    @TableField("like_count")
    private Integer likeCount;

    /**
     * 收藏数
     */
    @TableField("favorite_count")
    private Integer favoriteCount;

    /**
     * 评分
     */
    @TableField("rating")
    private BigDecimal rating;

    /**
     * 是否VIP作品
     */
    @TableField("is_vip")
    private Boolean isVip;

    /**
     * 价格
     */
    @TableField("price")
    private BigDecimal price;

    /**
     * 创建时间
     */
    @TableField(value = "created_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedTime;

    /**
     * 发布时间
     */
    @TableField("published_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime publishedTime;

    /**
     * 作者名称（TXT导入时从文件中解析）
     */
    @TableField("author_name")
    private String authorName;
}

